package com.itzhigui.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author java1412
 * @since 2023-11-01 17:14:24
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ResponseUtil implements Serializable {

    private Integer code;
    private String msg;
    private Object data;

    // 成功
    public static ResponseUtil ok(String msg, Object obj) {
        return new ResponseUtil(200, msg, obj);
    }

    // 失败
    public static ResponseUtil fail(String msg) {
        return new ResponseUtil(400, msg, null);
    }
}
